class P10363 {

	//	 1. X starts first, so at least X==O or X==O+1
	//	 2. Either X win and O not win and X==O+1,
	//	     or O win and X not win and X==O,
	//	     or neither win
	//	 3. nothing else

	public static void main(String[] args) {
		try {
		int cases = Integer.parseInt(readLn());
		for (int k = 0; k < cases; k++) {
			process();
			readLn();
		}
		} catch (Exception e) {
			while (true) {
				
			}
		}
	}

	private static void process() {
		char[][] grid = new char[3][3];
		int x = 0;
		int o = 0;
		for (int k = 0; k < 3; k++) {
			String line = readLn();
			for (int j = 0; j < 3; j++) {
				grid[k][j] = line.charAt(j);
				if (grid[k][j] == 'X') {
					x++;
				} 
				if (grid[k][j] == 'O') {
					o++;
				}
			}
		}
		
		if (x == o || x == o+1) {
			if (won(grid, 'X') && !won(grid, 'O') && x == o+1) {
				System.out.println("yes");
				return;
			} else if (!won(grid, 'X') && won(grid, 'O') && x == o) {
				System.out.println("yes");
				return;
			} else if (!won(grid, 'X') && !won(grid, 'O')) {
				System.out.println("yes");
				return;
			}
		}
		
		System.out.println("no");
//		if (x == o || x == o+1) {
//			if ()
//		}
	}


	private static boolean won(char[][] grid, char c) {
		if (grid[0][0] == c && grid[0][1] == c && grid[0][2] == c) {
			return true;
		}
		if (grid[1][0] == c && grid[1][1] == c && grid[1][2] == c) {
			return true;
		}
		if (grid[2][0] == c && grid[2][1] == c && grid[2][2] == c) {
			return true;
		}
		if (grid[0][0] == c && grid[1][0] == c && grid[2][0] == c) {
			return true;
		}
		if (grid[0][1] == c && grid[1][1] == c && grid[2][1] == c) {
			return true;
		}
		if (grid[0][2] == c && grid[1][2] == c && grid[2][2] == c) {
			return true;
		}
		if (grid[0][0] == c && grid[1][1] == c && grid[2][2] == c) {
			return true;
		}
		if (grid[0][2] == c && grid[1][1] == c && grid[2][0] == c) {
			return true;
		}		
		return false;
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}